package pers.baiban.sqltoword.handler;

import org.apache.poi.xwpf.usermodel.XWPFTable;
import org.apache.poi.xwpf.usermodel.XWPFTableCell;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTcBorders;
import pers.baiban.sqltoword.util.TableUtil;

import java.util.List;

import static pers.baiban.sqltoword.util.TableUtil.Functors.*;

/**
 * 表头边框辅助处理器接口
 *
 * @author 强子初
 * @since 2023/11/29
 */
public interface HeaderProcessor extends GenProcessor {

    /**
     * 获取 List<CTTcBorders>
     */
    default List<CTTcBorders> getCTTcBorders(XWPFTable table) {
        List<XWPFTableCell> cells = table.getRow(0).getTableCells();
        return TableUtil.to(cells, CTTC.andThen(TCPR).andThen(BORDERS));
    }
}